#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <time.h>
#include <conio.h>
#include <windows.h>

#include "Menu.h"
#include "Setting.h"
#include "RandomSnake.h"
#include "Snake.h"
#include "RandomMaze.h"

//全屏控制台窗口,取消标题栏及边框
void full_screen()
{
    HWND hwnd = GetForegroundWindow();
    int cx = GetSystemMetrics(SM_CXSCREEN);            /* 屏幕宽度 像素 */
    int cy = GetSystemMetrics(SM_CYSCREEN);            /* 屏幕高度 像素 */

    LONG l_WinStyle = GetWindowLong(hwnd, GWL_STYLE);   /* 获取窗口信息 */
    /* 设置窗口信息 最大化 取消标题栏及边框 */
    SetWindowLong(hwnd, GWL_STYLE, (l_WinStyle | WS_POPUP | WS_MAXIMIZE) & ~WS_CAPTION & ~WS_THICKFRAME & ~WS_BORDER);

    SetWindowPos(hwnd, HWND_TOP, 0, 0, cx, cy, 0);
}

//隐藏光标函数
void HideCursor()
{
    CONSOLE_CURSOR_INFO cursor_info = { 1,0 };//第二个值为0表示隐藏光标
    SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE), &cursor_info);
}


void init()
{
    full_screen();
    HideCursor();
}

int main()
{
    //TODO:设置控制台窗口大小
    //TODO:设置贪吃蛇前进速度

    int choose = 1;
    int start = 1;

    init();

    while (start)
    {
        choose = mainMenu();

        switch (choose)
        {
        case 0: start = 0; break;
        case 1: RandomSnake(); break;
        case 2: Snake(); break;
        case 3: RandomMaze(); break;
        case 4: Setting(); break;
        case -1:
            printf("Please input a number.\n");
            system("pause");
            break;
        default:
            printf("There is no %d\n", choose);
            system("pause");
            break;
        }
    }
    return 0;
}
